package wu.seal.utils

import com.winterbe.expekt.should
import org.junit.Test
import java.io.File
import java.util.*

class UtilsKtTest {

    @Test
    fun isPhoneLogCommend() {
        "-pt".isPhoneLogCommend().should.be.`true`
        "-ptd".isPhoneLogCommend().should.be.`true`
        "-pd".isPhoneLogCommend().should.be.`true`
        "-pdd".isPhoneLogCommend().should.be.`true`
        "-pted".isPhoneLogCommend().should.be.`true`
        "-pte".isPhoneLogCommend().should.be.`true`
        "-ptest".isPhoneLogCommend().should.be.`true`

        "-ptt".isPhoneLogCommend().should.be.`false`
        "-ptdt".isPhoneLogCommend().should.be.`false`
        "-pdsd".isPhoneLogCommend().should.be.`false`
        "-pddad".isPhoneLogCommend().should.be.`false`
    }


    @Test
    fun copyPhoneLogTest() {
        val destDir = File("./tempDirSealWu666")
        destDir.exists()
        destDir.deleteRecursively()
        destDir.mkdirs()
        copyPhoneLog("-ptd", destDir.absolutePath)
        destDir.listFiles().size.should.above(0)
        val copyedLodDir = destDir.listFiles().filter { it.name == "log" }[0]
        copyedLodDir.listFiles().size.should.above(0)
        copyedLodDir.listFiles().map { it.name }.joinToString().should.contain(Calendar.getInstance().get(Calendar.YEAR).toString())
        destDir.deleteRecursively()
    }


    @Test
    fun testSort() {
        val list = listOf("2019-01-02","2019-03-02","2019-01-03","2019-02-02")
        println(list.sorted())
    }
}